package util;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class JdbcUtils2 {
    private static DataSource ds = new DataSource();

    /**
     * 获取连接
     *
     * @return
     */
    public static Connection dbconn() {
        return DataSource.getConnection();
    }

    /**
     * 释放资源
     *
     * @param rs
     * @param pstmt
     * @param conn
     */
    public static void closeconn(ResultSet rs, Statement pstmt, Connection conn) {
        if (rs != null) {
            try {
                rs.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        if (pstmt != null) {
            try {
                pstmt.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        if (conn != null) {
            DataSource.free(conn);
        }
    }
}
